<?php
/*
  $Id: contact_us.php,v 1.42 2003/06/12 12:17:07 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

require('includes/application_top.php');

$error = false;
if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {
	$name = tep_db_prepare_input($HTTP_POST_VARS['name']);
	$email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);
	$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);
	
	if (tep_validate_email($email_address)) {
		tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);
		
		tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));
	} else {
		$error = true;
		$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
	}
}

if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {
	$theme->display('contact_us_success.tpl');
} else {
	$theme->display('contact_us.tpl');
}

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>
